function [ROI_X ROI_Y] = getSegmentROI(SegmentFile)

% This function takes a ROI created with the Segment program and imports
% the ROI coordinates for use in the ShearView program

% AJB, 8/16/2007

if nargin < 1
    [FileName, PathName] = uigetfile('*.seg','Select Segment File');
    if isequal(FileName,0)
        beep
        disp('User selected Cancel')
        return
    end
    SegmentFile = [PathName  FileName];
    [FileName, PathName] = uigetfile('*.dcm','Select Intensity File');
    IntensityFile = [PathName FileName];
end    

% Rename Segment file into .mat file
copyfile(SegmentFile, 'tempSeg.mat')

% Load Segment data
load('tempSeg.mat');
delete('tempSeg.mat')

% Save ROI coords
% check for segment version greater than 1.8 (since change to ROI structure)
swVersion = str2double(SEG.ProgramVersion(1:3));
if swVersion > 1.8
    ROI_X = SEG.Roi.X; 
    ROI_Y = SEG.Roi.Y;
else
    ROI_X = SEG.RoiX; 
    ROI_Y = SEG.RoiY;
end
% ROI_X = RoiX; 
% ROI_Y = RoiY;

        
if nargin < 1

    [countInt,SeriesNumInt] = countDICOMFiles(PathName);
    
    for t=1:countInt
        
        % Intensity Info.

        filepath           = [PathName '/IM-' ...
            num2str(SeriesNumInt,'%0.4d') '-'...
            num2str(t,'%0.4d') ];
        IntensityInfo      = dicominfo(filepath);
        IntensityImageTemp = dicomread(IntensityInfo);
        
        imagesc(IntensityImageTemp)
        axis image
        axis off
        colormap gray
        hold on
        plot(ROI_Y(:,t),ROI_X(:,t),'g','LineWidth',2.5)
        title(t)        
        hold off
        drawnow
    end
end